/*-------------------------------------------------------------------------------------------------------------------------
	Clean up the map
	Just a rip of a stock plugin for evovle made to work for wpp
-------------------------------------------------------------------------------------------------------------------------*/

local PLUGIN = {}
PLUGIN.Title = "WPP"
PLUGIN.Description = "Wolf Prop Protection."
PLUGIN.Author = "Goluch"
PLUGIN.ChatCommand = "clear"
PLUGIN.Usage = "[player]"
PLUGIN.Privileges = { "WPPClear","WPPAdmin" }

function PLUGIN:Call( Player, args )
	
	if ( Player:EV_HasPrivilege( "WPPCleanup" ) ) then
		local players = evolve:FindPlayer( args, Player, true )
			
		if ( #players > 0 ) then
			for _, ply in ipairs( players ) do
				if ( Player:EV_BetterThan( ply ) ) then
					WPP:CleanUp(ply:SteamID())
				end
			end
			
			evolve:Notify( evolve.colors.blue, ply:Nick(), evolve.colors.white, " has cleaned up the entities of ", evolve.colors.red, evolve:CreatePlayerList( players ), evolve.colors.white, "." )
		else
			evolve:Notify( ply, evolve.colors.red, evolve.constants.noplayers )
		end
	else
		evolve:Notify( ply, evolve.colors.red, evolve.constants.notallowed )
	end
end

function PLUGIN:Menu( arg, players )
	if ( arg ) then
		RunConsoleCommand( "ev", "cleanup", unpack( players ) )
	else
		return "CleanUp", evolve.category.wpp
	end
end

function PLUGIN:WPPAdminCheck(Index,Player,Owner)
	local Int = GetConVarNumber("wpp_allow_admins")
	if ( Int <= 0 ) then return false end
	if ( !Player:EV_HasPrivilege( "WPPAdmin" ) ) then return false end
	if ( !Player:EV_BetterThan( Owner ) ) then return false end
	return true
end

evolve:RegisterPlugin( PLUGIN )